# coding=utf-8
"""
Custom menu for fluent_dashboard apps.
"""
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from admin_tools.menu import items, Menu
from admin_tools.utils import get_admin_site_name
from fluent_dashboard.items import CmsModelList, ReturnToSiteItem
from fluent_dashboard.appgroups import get_application_groups



class FluentMenu(Menu):
    """
    Custom Menu for admin site.

    The top level menu items created by this menu reflect the application groups
    defined in :ref:`FLUENT_DASHBOARD_APP_GROUPS`. By using both
    the :class:`~fluent_dashboard.dashboard.FluentIndexDashboard` and this class,
    the menu and dashboard modules at the admin index page will consistent.
    The :class:`~fluent_dashboard.items.ReturnToSiteItem` is also added at the end of the menu.

    To activate the menu add the following to your settings.py::

        ADMIN_TOOLS_MENU = 'fluent_dashboard.menu.FluentMenu'
    """
    def init_with_context(self, context):
        """
        Initialize the menu items.
        """
        site_name = get_admin_site_name(context)

        self.children += [
            items.MenuItem(_('Estoque de Produtos'), reverse('%s:index' % site_name)),
            items.Bookmarks(),
            items.MenuItem('Utilitários',
                children=[
                    items.MenuItem('Compras',
                        children=[
                            items.MenuItem('Adicionar Compra', '/admin/controle/pedido/add/'),
                            items.MenuItem('Visualizar Compras', '/admin/controle/pedido/'),
                            ]),
                    items.MenuItem('Revenda',
                        children=[
                            items.MenuItem('Adicionar Revenda', '/admin/controle/revenda/add/'),
                            items.MenuItem('Visualizar Revendas', '/admin/controle/revenda/'),
                            ]),
                    items.MenuItem('Empresas',
                        children=[
                            items.MenuItem('Adicionar Empresa', '/admin/controle/fornecedor/add/'),
                            items.MenuItem('Visualizar Empresas', '/admin/controle/fornecedor/'),
                            ]),
                    items.MenuItem('Marcas',
                        children=[
                            items.MenuItem('Adicionar Marca', '/admin/controle/marcas/add/'),
                            items.MenuItem('Visualizar Marcas', '/admin/controle/marcas/'),
                            ]),
                    items.MenuItem('Tabelas de Frete e Custo',
                        children=[
                            items.MenuItem('Adicionar Tabela', '/admin/controle/tabela/add/'),
                            items.MenuItem('Visualizar Tabelas', '/admin/controle/tabela/'),
                            ]),
                    items.MenuItem('Estoque',
                        children=[
                            items.MenuItem('Adicionar Produto', '/admin/controle/produto/add/'),
                            items.MenuItem('Visualizar Estoque', '/admin/controle/produto/'),
                            items.MenuItem('Galeria de Fotos', '/admin/controle/galeriafotos/'),
                            ]),

                    ]),
            items.MenuItem('Relatórios',
                children=[
                    items.MenuItem('Produtos de fornecedores', '/admin/controle/compraprodutofornecedor/'),
                    items.MenuItem('Produtos com Vendedores', '/admin/controle/compraprodutovendedor/'),
                ]),
            items.MenuItem('Controle de Usuários','/admin/auth/'),
        ]



        self.children += [
            ReturnToSiteItem()
        ]


